package com.probiz.estore.system.dao.impl;

import java.util.List;

import org.hibernate.Query;

import com.probiz.estore.common.model.system.PaymentGateway;
import com.probiz.estore.core.dao.impl.HibernateGenericDaoImpl;
import com.probiz.estore.system.dao.PaymentGatewayDao;


/**
 * PaymentGateway Data Access Object (DAO) implementation.
 * Developer introduced interfaces should be declared here. Won't get overwritten.
*/
public class PaymentGatewayDaoImpl extends HibernateGenericDaoImpl<PaymentGateway> implements PaymentGatewayDao {
	
	public List<PaymentGateway> getAllByIsAdd(Short isAdd) {
	
		return this.findByHql(" from PaymentGateway vo where vo.isAdded=? order by vo.sortOrder asc" , isAdd);
	}
	
	public void updateIsAddedStatus(Integer paymentGatewayId, Short isAdded) {
		
		String updSql="Update PaymentGateway set isAdded=" + isAdded + " where paymentGatewayId=" + paymentGatewayId;
		
		Query query=getSession().createQuery(updSql);
		
		query.executeUpdate();
		
	}
	
	/**
	 * @see com.probiz.estore.system.dao.PaymentGatewayDao#getByPaymentGatewayCode(String)
	 */
	public PaymentGateway getByPaymentGatewayCode(String paymentGatewayCode) {
	    String hql="from PaymentGateway vo where vo.paymentGatewayCode=?";
	    PaymentGateway pg=(PaymentGateway)findUnique(hql,paymentGatewayCode);
        return pg;
    }
}